package framework.grid;

/**
 * This concrete class defines a way to reference a location within a Grid.
 * 
 * @author Bill Ge, May Zhai, Alex Yoo
 *
 */
public class Location {
	
	/** int Constants referring to their respective cardinal directions. */
	final static int NORTH = 0;
	final static int SOUTH = 1;
	final static int WEST = 2;
	final static int EAST = 3;
	final static int NORTHEAST = 4;
	final static int NORTHWEST = 5;
	final static int SOUTHEAST = 6;
	final static int SOUTHWEST = 7;
	
	/** Current row */
	private int row = -1;
	/** Current column */
	private int col = -1;
	
	/** Constructor makes a given location with the given row and column. */
	public Location(int row, int col){
		this.row = row;
		this.col = col;
	}
	
	/**
	 * Equals method returns whether this Location equals a given Location or
	 * not via equating their rows and columns.
	 * 
	 * @return true if other and this have the same column and row values.
	 */
	public boolean equals(Object other){
		Location temp = (Location) other;
		if(temp.getCol()==getCol() && temp.getRow()==getRow()){
			return true;
		}
		return false;
	}
	
	/**
	 * @return the given row of the Location.
	 */
	public int getRow(){
		return row;
	}
	
	/**
	 * @return the given col of the Location.
	 */
	public int getCol(){
		return col;
	}
	
	/**
	 * Provides a String representation of this Location.
	 * <br> String is represented in the form of (x, y)
	 */
	public String toString(){
		return "(" + getRow() + ", " + getCol() + ")"; 
	}
}
